/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http:  // www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef FINANCE_INNERKITS_PRINTER_ADAPTOR_H
#define FINANCE_INNERKITS_PRINTER_ADAPTOR_H

#include <iadaptor.h>
#include <string>
#include <map>
#include "recptprinter_def.h"

namespace SwanLink {
namespace Finance {

class IPrinterAdaptor:public IAdaptor
{
 public:
    virtual int GetPrintFormat(PrintFormatType ftt) = 0;
    virtual void SetPrintFormat(PrintFormatType ftt, int value) = 0;
    virtual void GetDeviceSpec(DeviceSpec &spec) = 0;
    virtual int FeedPaper(int line) = 0;
    virtual int CutPaper(int line, int mode) = 0;
    virtual int AddText(int x, int y, const std::string& text) = 0;
    virtual int AddBitmap(int x, int y, const std::string& lpPath) = 0;
    virtual int AddQRCode(int x, int y, int w, const std::string& qr) = 0;
    virtual int AddBarCode(int x, int y, BarCodeSpec &spec, const std::string& bar) = 0;
    virtual void StartPrint(int timeout, PrintListener *listener) = 0;
};

// 任务类型
enum PrintTaskType
{
    PT_TYPE_EMPTY = 0,
    PT_TYPE_TEXT,
    PT_TYPE_BITMAP,
    PT_TYPE_QRCODE,
    PT_TYPE_BARCODE
};
// 打印格式
struct PrintFormat
{
    PrintFormat() {
        align = PF_ALIGN_LEFT;
        density = PF_DENSITY_MEDIUM;
        bold = false;
        reverse = false;
        inversion = false;
        linethrough = PF_LINETHROUGH_NONE;
        size = PF_SIZE_EXTRASMALL;
        italic = false;
        hriloc = PF_HRILOC_NONE;
        width = 1;
        height = 1;
    }
    int width;
    int height;
    uint16_t density;
    bool bold;
    bool reverse;
    bool inversion;
    uint16_t linethrough;
    uint16_t size;
    uint16_t align;
    bool italic;
    uint16_t hriloc;
};
// 任务数据项
struct PrintItem
{
    //内容类型
    PrintTaskType ppt; 
    // 打印区域
    int x;
    int y;
    //打印格式
    PrintFormat fmt;
    // 打印内容
    std::string content;
};

}  // namespace Finance
}  // namespace SwanLink
#endif  // FINANCE_INNERKITS_PRINTER_ADAPTOR_H
